home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / contrib / xmu / GNU / winterp.el < prev    next >
Encoding:
Text File  |  1991-10-06  |  8.2 KB  |  207 lines

  1. ; -*-Emacs-Lisp-*-
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ; File:         winterp2.el
  5. ; RCS:          $Header: winterp.el,v 1.2 89/12/15 17:48:27 mayer Exp $
  6. ; Description:  GNUEMACS lisp-mode interface to WINTERP.
  7. ; Author:       Niels Mayer, HPLabs. 
  8. ;        Modified by Richard Hess, cimshop!rhess@uunet.UU.NET.
  9. ; Created:      Tue Nov 14 23:14:54 1989
  10. ; Modified:     Fri Dec 15 17:46:07 1989 (Niels Mayer) mayer@hplnpm
  11. ; Language:     Emacs-Lisp
  12. ; Package:      N/A
  13. ; Status:       X11r5 contrib tape release
  14. ;
  15. ; WINTERP Copyright 1989-1991 Hewlett-Packard Company (by Niels Mayer).
  16. ; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  17. ;
  18. ; Permission to use, copy, modify, distribute, and sell this software and its
  19. ; documentation for any purpose is hereby granted without fee, provided that
  20. ; the above copyright notice appear in all copies and that both that
  21. ; copyright notice and this permission notice appear in supporting
  22. ; documentation, and that the name of Hewlett-Packard and David Betz not be
  23. ; used in advertising or publicity pertaining to distribution of the software
  24. ; without specific, written prior permission.  Hewlett-Packard and David Betz
  25. ; make no representations about the suitability of this software for any
  26. ; purpose. It is provided "as is" without express or implied warranty.
  27. ;
  28. ; HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  29. ; SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  30. ; IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  31. ; INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  32. ; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  33. ; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  34. ; PERFORMANCE OF THIS SOFTWARE.
  35. ;
  36. ; See ./winterp/COPYRIGHT for information on contacting the authors.
  37. ; Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  38. ; Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  39. ;
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41.  
  42. (defvar winterp2-client "wl"
  43.   "The full path name of the client program (ie 'wl') that sends lisp
  44. expressions to the winterp lisp server...")
  45.  
  46. (defvar winterp2-client-args nil
  47.   "This sets the arguments sent to 'wl'... [ must be a list of strings ]")
  48.  
  49. ;; --------------------------------------------------------------------------
  50.  
  51. (defun winterp-send-defun ()
  52.   "[ NEW ]:  A version of lisp-send-defun that talks to WINTERP's lisp server
  53. via the winterp client program 'wl'..."
  54.   (interactive)
  55.   (let ((loadfile (format "/tmp/wl%d.lsp" (user-real-uid))))
  56.     (save-excursion (write-region
  57.              (progn (beginning-of-defun) (point))
  58.              (progn (end-of-defun) (point))
  59.              loadfile nil 'nomessage))
  60.     (apply 'start-process "winterp2-client" nil
  61.        winterp2-client
  62.        (append winterp2-client-args
  63.            (list (format
  64.               "(load \"%s\" :verbose nil :print t)"
  65.               loadfile))))
  66.     )
  67.   )
  68.  
  69. ;; --------------------------------------------------------------------------
  70.  
  71. (defun winterp-send-exit ()
  72.   "[ NEW ]:  Calling this function will send WINTERP a command to exit the
  73. current breaklevel. If not at a breaklevel, then WINTERP will exit..."
  74.   (interactive)
  75.   ;;sending wl with no args sends an EOF to WINTERP which signals XLISP to
  76.   ;;exit the current breaklevel, or exit if not in the breakloop.
  77.   (apply 'start-process "winterp2-client" nil
  78.      winterp2-client
  79.      winterp2-client-args)
  80.   )
  81.  
  82. ;; --------------------------------------------------------------------------
  83.  
  84. (defun winterp-send-buffer ()
  85.   "[ NEW ]:  A version of winterp-send-defun that sends the entire buffer off
  86. to WINTERP for evaluation. This routine talks to WINTERP's lisp server via the
  87. winterp client program 'wl'..."
  88.   (interactive)
  89.   (let ((loadfile (format "/tmp/wl%d.lsp" (user-real-uid))))
  90.     (save-excursion (write-region (point-min) (point-max)
  91.                   loadfile nil 'nomessage))
  92.     (apply 'start-process "winterp2-client" nil
  93.        winterp2-client
  94.        (append winterp2-client-args
  95.            (list (format
  96.               "(load \"%s\" :verbose nil :print t)"
  97.               loadfile))))
  98.     )
  99.   )
  100.  
  101. ;; ----------------------------------------------------------------[ contrib ]
  102. ;;; Date: Mon, 17 Dec 90 16:46:39 -0500
  103. ;;; From: rsw@cs.brown.edu (Bob Weiner)
  104. ;;; Message-Id: <9012172146.AA06790@fiddle.cs.brown.edu>
  105. ;;; To: mayer@hplnpm.hpl.hp.com
  106. ;;; Subject: Generalization of winterp.el code.
  107. ;;; 
  108. ;;; The generalization I include here substitutes an eval-last-sexp type 
  109. ;;; function for your send-defun.  The send-defun function may be left around 
  110. ;;; but really is not needed since all one need do is move to the end of the
  111. ;;; function and evaluate it.  This makes the interface so much simpler when
  112. ;;; one wants to do bottom up testing via the interpreter.
  113. ;;; 
  114. ;;; I've included only the one function and the key binding, so you should
  115. ;;; substitute it into your winterp.el file.
  116.  
  117. (defun winterp-eval-last-sexp ()
  118.   "[ NEW ]:  A version of eval-last-sexp that talks to WINTERP's lisp server
  119. via the winterp client program 'wl'.  Evaluates sexp immediately preceding
  120. point..."
  121.   (interactive)
  122.   (let ((loadfile (format "/tmp/wl%d.lsp" (user-real-uid)))
  123.     (stab (syntax-table)))
  124.     (write-region
  125.      (unwind-protect
  126.      (save-excursion
  127.        (set-syntax-table emacs-lisp-mode-syntax-table)
  128.        (forward-sexp -1)
  129.        (point))
  130.        (set-syntax-table stab))
  131.      (point)
  132.      loadfile nil 'nomessage)
  133.     (apply 'start-process "winterp2-client" nil
  134.        winterp2-client
  135.        (append winterp2-client-args
  136.            (list (format
  137.               "(load \"%s\" :verbose nil :print t)"
  138.               loadfile))))
  139.     )
  140.   )
  141.  
  142. ;; ----------------------------------------------------------------[ contrib ]
  143. ;;; Date: Mon, 17 Dec 90 16:56:32 -0500
  144. ;;; From: rsw@cs.brown.edu (Bob Weiner)
  145. ;;; Message-Id: <9012172156.AA06799@fiddle.cs.brown.edu>
  146. ;;; To: mayer@hplnpm.hpl.hp.com
  147. ;;; Subject: Further generalization of winterp.el code.
  148. ;;; 
  149. ;;; We can further simplify the interface by combinding the expression 
  150. ;;; evaluation command with the buffer evaluation command.  The latter is
  151. ;;; called when a prefix argument is sent to the 'winterp-eval' command.  
  152. ;;; Thus, only one key is needed, but both functions are accessible.  Try it.
  153. ;;;
  154.  
  155. (defun winterp-eval (&optional arg)
  156.   "Evaluate last sexpression.  With prefix ARG, evaluate visible portion of buffer."
  157.   (interactive "P")
  158.   (if arg
  159.       (winterp-send-buffer)
  160.     (winterp-eval-last-sexp)))
  161.  
  162. ;; ----------------------------------------------------------------[ contrib ]
  163. ;;; To: mayer@hplabs.hpl.hp.com
  164. ;;; Cc: gildea@alexander.bbn.com
  165. ;;; Subject: XLisp comments
  166. ;;; Date: Tue, 02 Oct 90 11:45:16 EDT
  167. ;;; From: Stephen Gildea <gildea@alexander.bbn.com>
  168. ;;; 
  169. ;;; I found I needed the function winterp-send-region, so I added it to
  170. ;;; winterp.el.  Here it is:
  171.  
  172. (defun winterp-send-region (start end)
  173.   "[ NEW ]:  Send the current region off to WINTERP for evaluation.
  174. This routine talks to WINTERP's lisp server via the winterp client
  175. program 'wl'..."
  176.   (interactive "r")
  177.   (let ((loadfile (format "/tmp/wl%d.lsp" (user-real-uid))))
  178.     (save-excursion (write-region start end loadfile nil 'nomessage))
  179.     (apply 'start-process "winterp2-client" nil
  180.        winterp2-client
  181.        (append winterp2-client-args
  182.            (list (format
  183.               "(load \"%s\" :verbose nil :print t)"
  184.               loadfile))))
  185.     ))
  186.  
  187. ;; --------------------------------------------------------------------------
  188. ;; rebind some keys in lisp-mode-map (assumed preloaded in gnuemacs).
  189. ;; --------------------------------------------------------------------------
  190.  
  191. (define-key lisp-mode-map "\C-c\C-d" 'winterp-send-exit)
  192. (define-key lisp-mode-map "\e\C-x"   'winterp-send-defun)
  193. (define-key lisp-mode-map "\e\C-x"   'winterp-eval-last-sexp)
  194. (define-key lisp-mode-map "\M-\C-x"  'winterp-eval)
  195.  
  196. ;; NPM??? -- (if (eq window-system 'x)
  197. ;; NPM??? --     (progn (xterm-bind-key "L2"        'winterp-send-buffer)
  198. ;; NPM??? --        (xterm-bind-key "L4"        'winterp-send-defun)
  199. ;; NPM??? --        (xterm-bind-key "L3"        'winterp-eval-last-sexp)
  200. ;; NPM??? --        (xterm-bind-key "L5"        'winterp-eval)
  201. ;; NPM??? --        (xterm-bind-key "L6"        'winterp-send-region)
  202. ;; NPM??? --        (xterm-bind-key "L10"    'winterp-send-exit)
  203. ;; NPM??? --        ))
  204.  
  205. ;; ---------------------------------------------------------------------<eof>
  206.